<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------
namespace app\user_center\behavior\user\refresh_token_before;

/**
 * 检验用户和refresh_token有效性
 * @package app\user_center\behavior\user\refresh_token_before
 * @author shiqiang
 */
class checkRefreshtoken{
    /**
     * 执行行为 run方法是Behavior唯一的接口
     * @access public
     * @return void
     */
    public function run($params){
		$uid = $params['uid'];
		$refresh_token = $params['refresh_token'];
		
		$map = [];
		$map['uid'] = $uid;
		$result = model('UcMemberAuthtoken', 'model\user') -> where($map) -> find();
		if(!empty($result)){
			$result_refresh_token = $result->refresh_token;
			if($refresh_token != $result_refresh_token){
				return array_out(-1001,'token无效');
			}
		}else{
			return array_out(-1001,'token无效');
		}
    }
}
